package cc.lcdsg.utils;

import java.io.IOException;
import java.io.InputStream;

public class StreamUtils {
	
	/**
	 * @param is
	 * @param charset 流的格式
	 * @return
	 * @throws IOException
	 */
	public static String inputStreamToString(InputStream is, String charset) throws IOException {
		byte[] bytes = new byte[1024];
		int byteLength = 0;
		StringBuffer sb = new StringBuffer();
		while((byteLength = is.read(bytes)) != -1) {
			sb.append(new String(bytes, 0, byteLength, charset));
		}
		return sb.toString();
	}
}
